import 'package:redux/redux.dart';
import 'package:stock_check/common/model/Works.dart';
import 'package:stock_check/common/model/checkITDeviceItem.dart';
import 'package:stock_check/common/model/taskItem.dart';

final updateCheckDevicesReducer = combineReducers<Works>([
  TypedReducer<Works,UpdateCheckITDevicesAction>(_updateCheckITDeviceWork),
  TypedReducer<Works,UpdateCheckInstitutionsAction>(_updateInstitutionsDeviceWork),
  TypedReducer<Works,UpdateLastUpdateDay>(_updateLastUpdateDay),
  TypedReducer<Works,UpdateTasksAction>(_updateTasksWork)
]);


/// 更新盘点任务列表
class UpdateTasksAction {
  final List<TaskItem> tasks;
  UpdateTasksAction({this.tasks});
}

Works _updateTasksWork(Works worksInfo,action){
  worksInfo.tasks = action.tasks;
  return worksInfo;
}


Works _updateCheckITDeviceWork(Works workInfo, action) {
  workInfo.checkITDevices = action.checkITDeviceItems;
  return workInfo;
}

Works _updateInstitutionsDeviceWork(Works workInfo, action) {
  workInfo.institutions = action.checkInstitutionItems;
  return workInfo;
}

Works _updateLastUpdateDay(Works workInfo,action){
  workInfo.lastUpdateDay = action.dateStr;
  return workInfo;
}

/// 更新最近一次的更新日期
class UpdateLastUpdateDay{
  final String dateStr;
  UpdateLastUpdateDay({this.dateStr});
}

/// 更新待寻检IT设备任务列表
class UpdateCheckITDevicesAction {
  final List<CheckITDeviceItem> checkITDeviceItems;
  UpdateCheckITDevicesAction({this.checkITDeviceItems});
}


/// 更新待寻检设施类设备任务列表
class UpdateCheckInstitutionsAction {
  final List<CheckITDeviceItem> checkInstitutionItems;
  UpdateCheckInstitutionsAction({this.checkInstitutionItems});
}

